package com.seventh.parkingrent.dao;

import com.seventh.parkingrent.controller.form.ParkingSpaceAuditFormForFront;
import com.seventh.parkingrent.domain.ParkingSpaceAudit;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 停车场审核记录表 Mapper 接口
 * </p>
 *
 * @author Lucas
 * @since 2021-08-25
 */
public interface ParkingSpaceAuditMapper extends BaseMapper<ParkingSpaceAudit> {

    @Select("<script>" +
            "select distinct * from pr_parking_space_audit psa,pr_parking_space ps,pr_manager m,pr_user u,pr_property_manager pm " +
            "where psa.parking_space_id =ps.parking_space_id and psa.manager_id = m.manager_id and u.user_id=ps.user_id and ps.property_manager_id =pm.property_manager_id " +
            "<if test='null!=managerName'>and m.manager_name = #{managerName} </if>" +
            "<if test='null!=username'>and u.username = #{username} </if>" +
            "<if test='null!=propertyName'>and pm.property_name = #{propertyName} </if>" +
            "<if test='null!=parkingSpaceAddr'>and ps.parking_space_addr = #{parkingSpaceAddr} </if>" +
            "and date(psa.row_add_time) between #{beginDate} and #{endDate} " +
            "order by psa.row_add_time desc" +
            "</script>")
    List<ParkingSpaceAuditFormForFront> selectParkingSpaceAuditByCondition(@Param("managerName") String managerName,
                                                                           @Param("username") String username,
                                                                           @Param("propertyName") String propertyName,
                                                                           @Param("parkingSpaceAddr") String parkingSpaceAddr,
                                                                           @Param("beginDate") Date beginDate,
                                                                           @Param("endDate") Date endDate);
}
